home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / role / DebugTool_111.lha / srcmacros.c < prev    next >
C/C++ Source or Header  |  1992-10-31  |  3KB  |  132 lines

  1. #include "frobnitz.h"
  2.  
  3. /*******************************************************************/
  4. /* Funktion: ReadMacros                                           */
  5. /*******************************************************************/
  6.  
  7. void
  8. ReadMacros ()
  9. {
  10.   short int i, j;
  11.   z_word macro_pos[3 * 32];
  12.   long int twobytes;
  13.   byte count, is_end;
  14.  
  15.   seek_pos (header.macro_offset);
  16.  
  17. #ifdef DEBUG
  18.   printf ("<MAC-T-BEG:$%04x>\n", ftell (DatFile));
  19. #endif
  20.  
  21.   for (i = 0; i < 3; i++)
  22.     {
  23.       for (j = 0; j < 32; j++)
  24.     {
  25.       macro_pos[i * 32 + j] = 2 * ((fgetc (DatFile) * 256) + fgetc (DatFile));
  26.     }
  27.     }
  28.  
  29. #ifdef DEBUG
  30.   printf ("<MAC-T-END:$%04x>\n", ftell (DatFile));
  31. #endif
  32.  
  33.   for (i = 0; i < 3; i++)
  34.     {
  35.       for (j = 0; j < 32; j++)
  36.     {
  37.       seek_pos (macro_pos[i * 32 + j]);
  38.  
  39. #ifdef DEBUG
  40.       if ((i == j) && (j == 0))
  41.         printf ("<MAC-S-BEG:$%04x>\n", ftell (DatFile));
  42. #endif
  43.  
  44.       count = 1;
  45.       is_end = 0;
  46.  
  47.       while (!(is_end))
  48.         {
  49.           twobytes = (256 * fgetc (DatFile) + fgetc (DatFile));
  50.           is_end = (twobytes > 0x7fff);
  51.  
  52.           EncodedString[count] = (twobytes & 0x7c00) / 0x400;
  53.           EncodedString[count + 1] = (twobytes & 0x3e0) / 0x20;
  54.           EncodedString[count + 2] = (twobytes & 0x1f);
  55.  
  56.           count = count + 3;
  57.         }
  58.       EncodedString[0] = (count - 1);
  59.       EncodedString[count] = '\0';
  60.  
  61.       StringDecode ();
  62.  
  63.       if (PrintedChars > (MAXLEN_MACRO - 1))
  64.         quit (4);
  65.  
  66.       strcpy (macros[i * 32 + j], DecodedString);
  67.     }
  68.     }
  69.  
  70. #ifdef DEBUG
  71.   printf ("<MAC-S-END:$%04x>\n", ftell (DatFile));
  72. #endif
  73.  
  74.   macros_read = 1;
  75. }
  76.  
  77.  
  78. /*******************************************************************/
  79. /* Funktion: PrintMacros                                           */
  80. /*******************************************************************/
  81.  
  82. void
  83. PrintMacros (void)
  84. {
  85.   int i, j;
  86.  
  87.   printf ("MACROS:\n\n");
  88.  
  89.   printf ("\tM1\t\tM2\t\tM3\n");
  90.  
  91.   for (i = 0; i < 32; i++)
  92.     {
  93.       printf ("%d\t", i);
  94.       for (j = 0; j < 3; j++)
  95.     {
  96.       printf ("[");
  97.       PrintMacro (j, i);
  98.       printf ("%s", MacroString);
  99.       printf ("]\t");
  100.       if (MacroLength (j, i) < 6)
  101.         printf ("\t");
  102.     }
  103.       newline ();
  104.     }
  105. }
  106.  
  107.  
  108. /*******************************************************************/
  109. /* Funktion: PrintMacro                                            */
  110. /*******************************************************************/
  111.  
  112. /* i = 0..2 - j = 0...31  */
  113.  
  114. void
  115. PrintMacro (int i, int j)
  116. {
  117.   strcpy (MacroString, macros[i * 32 + j]);
  118. }
  119.  
  120.  
  121. /*******************************************************************/
  122. /* Funktion: MacroLength                                           */
  123. /*******************************************************************/
  124.  
  125. /* i = 0..2 - j = 0...31  */
  126.  
  127. int
  128. MacroLength (int i, int j)
  129. {
  130.   return (strlen (macros[i * 32 + j]));
  131. }
  132.